/*
 * 统计模块业务统计出院js
 * @author 杨腊梅
 * 2016/1/20
 * 
 */


$('#tcm_medicalTechnician_eCharts').css('height',orange.detailPage.getHeight());
$('#tcm_medicalTechnician_eCharts').css('width',orange.detailPage.getWidth());

$('#tcm_medicalTechnician_grid').datagrid(
		{
			url:"d/tech/table",
			queryParams:{orgGuid:$("#tcmcpdetail_guid").val()},
			singleSelect:true,
			rownumbers:true,
			columns:[[
			         {field:'technicianName',title:'姓名',width:'15%',sortable:true,halign:'center'},
			         {field:'technicianTitleName',title:"职称",width:'15%',sortable:true,halign:'center'},
			         {field:'licenseTypeName',title:"执照类型",width:'15%',sortable:true,halign:'center'},
			         {field:'age',title:"年龄",width:'8%',sortable:true,halign:'center'},	   
			         {field:'educationName',title:'学历',width:'15%',sortable:true,halign:'center'},
			         {field:'indate',title:"入馆时间",width:'15%',sortable:true,halign:'center'},
			         {field:'technicianSpecialityNames',title:"专长",width:'15%',sortable:true,halign:'center',formatter:function(value){
				          	var value_other = value == null ? "" : value;
				        	return '<span title="' + value_other + '">' + value_other + '</span>';
				        }}
			         ]],
			pagination:true,
			sortable:true,
			sortName: 'tcm_name',
			sortOrder: 'asc'
		}
);

/*
 * 图表数据初始化
 */
var tcm_myChart = echarts.init($('#tcm_medicalTechnician_eCharts')[0]);
var tcm_initData 
var tcm_serial_technician_sum = [];
var tcm_serial_technician_diagnosis = [];
var tcm_serial_technician_physiotherapy = [];
var tcm_xData = [];
$.ajax({
	url:'d/tech/chart',
	data:{orgGuid:$("#tcmcpdetail_guid").val()},
	success:function(data){
		tcm_initData = JSON.parse(data)
		for(var i=0; i<tcm_initData.length; i++) {
			tcm_serial_technician_sum.push(tcm_initData[i].tcm_technician_sum);
			tcm_serial_technician_diagnosis.push(tcm_initData[i].tcm_technician_diagnosis);
			tcm_serial_technician_physiotherapy.push(tcm_initData[i].tcm_technician_physiotherapy);
			tcm_xData.push(tcm_initData[i].period);
		}
		tcm_myChart.setOption(tcm_option);
	}
});


/*
 * 设置图表格式
 */
tcm_option={
		grid:{
			show:false,
			bottom :'15%',
			top:'25%',
			height:'65%',
			width:'80%',
			left:'10%',
			right:'15%'
		},
		
		tooltip : {
			trigger : 'axis'
		},
		
		legend : {
			top:'8%',
			data : ['技师总数', '诊断技师总数', '康复理疗技师宗总数']
		},
		
		xAxis : [{
			type : 'category',
			boundaryGap : false,
			data : tcm_xData
		}],
		
		yAxis : [{
			type:'value'
		}],
		
		series : [
		  {
			  type : 'line',
			  name : "技师总数",
			  smooth : true,
			  data : tcm_serial_technician_sum
		  },
		  {
			  type : 'line',
			  name : "诊断技师总数",
			  smooth : true,
			  data : tcm_serial_technician_diagnosis
		  },
		  {
			  type : 'line',
			  name : "康复理疗技师宗总数",
			  smooth : true,
			  data : tcm_serial_technician_physiotherapy
		  }
		],
};

//使用刚指定的配置项和数据显示图表
tcm_myChart.setOption(tcm_option);